﻿using UnityEngine;
using System.Collections;
using UnityEngine.UI;
using WoogiUI;
using System;

namespace WoogiUI
{
    [RequireComponent(typeof(Slider))]
    public class WoogiSlider : WoogiImage
    {
        private Action<float, GameObject> onChange;
        public Slider slider
        {
            get { return GetComponent<Slider>(); }
        }

        public void SetEvent(Action<float, GameObject> _event)
        {
            onChange = _event;
            slider.onValueChanged.AddListener(OnChange);
        }

        private void OnChange(float value)
        {
            if(onChange!=null)
            {
                onChange(value, gameObject);
            }
        }
    }
}
